<?php
$adminPrefix = '';
$isAdmin = false;
if(isset($this->params['admin']))
{
	$adminPrefix = '/admin';
	$isAdmin = true;
}
?>
<?php if($title){?>
	<h2><?php echo $title;?></h2>
<?php }?>
<div class = "view_page">
	<?php 
	$i = 0;
	foreach($galleryItems as $galleryItem) 
	{
		if(is_array($galleryItem) && isset($galleryItem[$model]))
		{
			$galleryItem = $galleryItem[$model];
		}
		if(strlen($galleryItem['name']) < 1)
		{
			continue;
		}
		if($i%$columns==0)
		{?>
			<div class='clear' ></div> 
		<?php }?>
		
	 	<div class="galleryImage">
		<div align="center">
	 		<?php echo $html->link($html->image($galleryItem['file_url'],$imgOptions),$adminPrefix.'/listing_assets/view/'.$galleryItem['id'],array('escape'=>false))?><br/>
	 		<?php echo __("By")?>
	 		<?php
	 		if($isAdmin != true)
	 		{
	 			echo $html->link($galleryItem['poster']['display_name'],$galleryItem['poster']['profile_url']);
	 		}else
	 		{
	 			
				$profileUrl = '/admin/users/view/'.$galleryItem['poster']['id'];
				if($galleryItem['poster_entity'] == 'Guest')
				{
					$profileUrl = 'javascript::void();';
				}
	 			echo $html->link($galleryItem['poster']['display_name'], $profileUrl);
	 		}?>
	 		<br/>
	 		<?php echo date('Y-m-d',strtotime($galleryItem['created']))?> 		<br/>
	 			</div>
	 		<?php if($isAdmin == true)
	 		{?>
	 			
	 			<?php
	 			if($galleryItem['is_default'] == 1)
	 			{?>
	 				<b><?php echo __("Default");?></b> | 
	 			<?php }else{?>
	 				<?php echo $html->link(__('Set as default'),$adminPrefix.'/listing_assets/setAsDefault/'.$galleryItem['id']);?> |
	 			<?php }?> 
	 			<?php
	 			if($galleryItem['status'] == ListingAsset::PUBLISHED)
	 			{
	 				$title = __('Unpublish'); 				
	 				
	 			}else
	 			{
	 				$title = __('Publish'); 				
	 			}
	 			?>
	 			<?php echo $html->link($title,'/admin/listing_assets/changeStatus/'.$galleryItem['id']);?> | 
	 			<?php echo $html->link(__('Delete'),$adminPrefix.'/listing_assets/delete/'.$galleryItem['id'],array(),__("Are you sure want to delete this photo?"));?>
	 		<?php }?>	
	 	</div>

	<?php $i++;
	}
	?>
			<div class='clear' ></div> 
</div>